<?php

use SinoPHP\BbdBoss\Library\Etcd;
use Upfor\UpforPHP\Model;
use SinoPHP\BbdBoss\Library\Dnspod;

require_once __DIR__ . '/../UpforPHP/bootstrap.php';
require_once __DIR__ . '/../vendor/autoload.php';

$dnspodObj = new Dnspod();
$navList = $dnspodObj->getDbRecordLines();

/**
 * 更新线路表ISP所属关系
 * 
 * @var array
 */
$dbData = array();
foreach ($navList as $lineList) {
    foreach ($lineList['subLines'] as $areaList) {
        if (empty($areaList['subLines'])) {
            $dbData[] = [
                'id' => $areaList['id'],
                // 'line_name' => $areaList['line_name'],
                'nav_group_id' => $lineList['id']
            ];
        } else {
            foreach ($areaList['subLines'] as $line) {
                $dbData[] = [
                'id' => $line['id'],
                // 'line_name' => $line['line_name'],
                'nav_group_id' => $lineList['id']
            ];
            }
        }
    }  
}

$dbRes = model("DomainDnspodLine")->insert($dbData, true);

var_dump($dbRes);
die;